package com.glsc.ngateway.common.base.repo.mysql.gateway.platform;

import com.glsc.ngateway.common.base.domain.mysql.gateway.platform.Appendix;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

@Repository
public interface AppendixRepo extends JpaRepository<Appendix, Long>, JpaSpecificationExecutor<Appendix> {


    @Transactional
    @Modifying
    @Query(value = "insert into t_oa_flow_append_table(appendix_name, appendix_id,appendix_path) value(:appendixName, :appendixId,:appendPath)", nativeQuery = true)
    void addAppendix(@Param("appendixName") String appendixName, @Param("appendixId") String appendixId, @Param("appendPath") String appendPath);

    @Query(value = "select a from Appendix a where a.appendixId = :appendixId")
    Appendix findById(@Param("appendixId") String appendixId);
}


